package 力扣;

import java.util.Arrays;

/**
 * @author ZhuYi
 * @create 2024/7/23 15:14
 */
public class 跳跃游戏_55 {
    public static void main(String[] args) {
        int[] nums = {3, 0, 8, 2, 0, 0, 1};
        System.out.println(canJump(nums));
    }

    public static boolean canJump(int[] nums) {
        int n = nums.length;
        int most = 0;
        for (int i = 0; i < n; i++) {
            if (i <= most) {
                most = Math.max(most, i + nums[i]);
                if (most >= n - 1) {
                    return true;
                }
            }
        }
        return false;
    }
}
